package cn.pugle.ormtest.hibernate.repository.mixin;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.Date;
import java.util.List;

/**
 * @author tzp
 * @date 2017/12/28
 */
public class MyBaseRepositoryImpl implements MyBaseRepository {
    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public void xx() {
//        Session session = entityManager.unwrap(org.hibernate.Session.class);
        List resultList = entityManager.createNativeQuery(
                "SELECT id,order_date,price,address FROM st_order3 WHERE order_date <= :recent")
                .setParameter("recent", new Date())
                .getResultList();
    }

    @Override
    public EntityManager getEntityManager() {
        return entityManager;
    }
}
